package cloud.dwz.service.impl;

import cloud.dwz.entity.SysAreaEntity;
import cloud.dwz.service.SysAreaService;
import io.wit.modules.dwz.SysAreaDao;
import io.wit.tool.ToolClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("sysAreaService")
public class SysAreaServiceImpl implements SysAreaService{

    @Autowired
	private SysAreaDao sysAreaDao;
	
	@Override
	public SysAreaEntity queryObject(final Long kid){
		return sysAreaDao.queryObject(kid);
	}
	
	@Override
	public List<SysAreaEntity> queryList(final Map<String, Object> map){
		return sysAreaDao.queryList(map);
	}
	
	@Override
	public int queryTotal(final Map<String, Object> map){
		return sysAreaDao.queryTotal(map);
	}
	
	@Override
	public int save(final SysAreaEntity sysArea){
        return sysAreaDao.save(sysArea);
	}
	
	@Override
	public int update(final SysAreaEntity sysArea){
        return sysAreaDao.update(sysArea);
	}
	
	@Override
	public int delete(final Long kid){
        return sysAreaDao.delete(kid);
	}
	
	@Override
	public int deleteBatch(final Long[] kids){
        return sysAreaDao.deleteBatch(kids);
	}

    /**通过父级id获取区域信息*/
    @Override
    public String getListArea(Long pId){
        if(pId == null){
            pId = 0L;
        }
        return ToolClient.queryJson(sysAreaDao.getListArea(pId));
    }

    @Override
    public String queryAreaTree(Long pid){
        if(pid == null){
            pid = 0L;
        }
        return ToolClient.queryJson(sysAreaDao.queryAreaTree(pid));
    }
}